package com.xijia.wuyouwallet.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xijia.wuyouwallet.R;

/**
 * Created by Administrator on 2017/7/25 0025.
 */

public class PayKeyAdapter extends BaseAdapter {

    private Context context;

    public PayKeyAdapter(Context context) {
        this.context=context;
    }

    private String[] texts = {
            //九宫格图片下方文字的设置
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7",
            "8",
            "9",
            ".",
            "0",
            "00",
    };

    private String[] types = {
            //存放在text的tag中
            "num",
            "num",
            "num",
            "num",
            "num",
            "num",
            "num",
            "num",
            "num",
            "point",
            "num",
            "num",
    };
    @Override
    public int getCount() {
        return texts.length;
    }
    @Override
    public Object getItem(int i) {
        return i;
    }
    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ImgTextWrapper wrapper;
        if(view==null) {
            wrapper = new ImgTextWrapper();
            LayoutInflater inflater = LayoutInflater.from(context);
            view = inflater.inflate(R.layout.grid_menu_item_pay, viewGroup,false);
            view.setTag(wrapper);
            //view.setPadding(3, 3, 3, 3);  //每格的间距
        } else {
            wrapper = (ImgTextWrapper)view.getTag();
        }

        wrapper.textView = (TextView)view.findViewById(R.id.GridTextView);
        wrapper.textView.setText(texts[i]);
        wrapper.textView.setTag(types[i]);

        return view;
    }
    class ImgTextWrapper {
        ImageView imageView;
        TextView textView;
    }
}
